package com.knife.bbs.business;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
*
* <p>Title:配置信息</p>
* <p>Description:调用配置信息处理类,处理并存放easyjf-web.xml中的配置信息</p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: www.easyjf.com</p>
* @author 蔡世友
* @author stef_wu
* @version 1.0
*/
public class BBSConfig {

private final List admins=new ArrayList();
private final Map messages=new HashMap();
private static String delay_time;
private static String host_name;
private final Map mails=new HashMap();
private static BBSConfig config;
private BBSConfig()
{	
	
}
public static BBSConfig getInstance()
{
	if(config==null){
		config=new BBSConfig();
	    config.init();
	}
	return config;
}
public void init()
{	
	if(admins!=null)admins.clear();
	if(messages!=null)messages.clear();
	if(mails!=null)mails.clear();
	delay_time="";
	try{		
		XMLConfigFactory icf=new XMLConfigFactory();
		icf.initAdmin(admins);
		icf.initSystemMessage(messages);			
		host_name=icf.initHostName();
		delay_time=icf.initTickTime();		
		icf.initMail(mails);	
	}
	catch(Exception e)
	{
		System.out.println("加载配置文件错误!"+e);
	}	

}

public List getAdmins() {
	return admins;
}
public void setConfig(BBSConfig config) {
	BBSConfig.config = config;
}
public String getDelay_time() {
	return delay_time;
}
public Map getMails() {
	return mails;
}
public Map getMessages() {
	return messages;
}
public String getHost_name() {
	return host_name;
}

}
